﻿<Window x:Class="RoutedEvents.TunneledKeyPress"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="TunneledKeyPress" Height="411" Width="403"
     PreviewKeyDown="SomeKeyPressed" 
    >
  <Grid Margin="3" >
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"></RowDefinition>
      <RowDefinition Height="*"></RowDefinition>
      <RowDefinition Height="Auto"></RowDefinition>
      <RowDefinition Height="Auto"></RowDefinition>
    </Grid.RowDefinitions>

    <Label Margin="5" Background="AliceBlue" BorderBrush="Black" BorderThickness="1" HorizontalContentAlignment="Stretch"
           PreviewKeyDown="SomeKeyPressed">
      <StackPanel
        PreviewKeyDown="SomeKeyPressed">
        <TextBlock Margin="3" HorizontalAlignment="Center"
                   PreviewKeyDown="SomeKeyPressed">
          Image and text label
        </TextBlock>
        <Image Source="happyface.jpg" Stretch="None" 
                PreviewKeyDown="SomeKeyPressed"/>
        <DockPanel Margin="0,5,0,0" PreviewKeyDown="SomeKeyPressed">
          <TextBlock Margin="3" 
                     PreviewKeyDown="SomeKeyPressed">
          Type here:
        </TextBlock>
          <TextBox PreviewKeyDown="SomeKeyPressed" KeyDown="SomeKeyPressed"></TextBox>
        </DockPanel>
      </StackPanel>
    </Label>

    <ListBox Margin="5" Name="lstMessages" Grid.Row="1"></ListBox>
    <CheckBox Margin="5" Grid.Row="2" Name="chkHandle">Handle first event</CheckBox>
    <Button Click="cmdClear_Click" Grid.Row="3" HorizontalAlignment="Right" Margin="5" Padding="3">Clear List</Button>
  </Grid>
</Window>
